#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define y1 y_alpha_1

using namespace std;

using ll = long long;
using db = double;
using vec = vector<int>;
using pii = pair<int,int>;

int read() {
	int x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-',ch = getchar();
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48),ch = getchar();
	return f ? -x : x;
}

const int N = 5e4 + 10;

int match[N],n,m,fa[22][N],to[N];
ll ans,dep[N];
bool v[N],hav[N];
vector < pii > G[N];

void dfs(int x,int p) {
	dep[x] = dep[p] + to[x]; fa[0][x] = p; for(int i = 1;i < 21;i++) fa[i][x] = fa[i - 1][fa[i - 1][x]];
	for(auto d : G[x]) if(d.fi != p) to[d.fi] = d.se,dfs(d.fi,x);
}

int get(int x,ll mid) {
	for(int i = 20;i >= 0;i--) if(fa[i][x] > 1 && dep[x] - dep[fa[i][x]] <= mid) mid -= dep[x] - dep[fa[i][x]],x = fa[i][x];
	return x;
}

void ddfs(int x,int p) {
	if(v[x]) return; if(x != 1 && G[x].size() == 1) hav[x] = 1;
	for(auto d : G[x]) if(d.fi != p) ddfs(d.fi,x),hav[x] |= hav[d.fi];
}

bool check(ll mid) {
	vector < ll > ned; vector < pair < long long , int > > lef; memset(v,0,sizeof v); memset(hav,0,sizeof hav);
	for(int i = 1;i <= m;i++) {
		int x = match[i]; int g = get(x,mid);
		if(fa[0][g] == 1 && dep[x] <= mid) lef.pb({ mid - dep[x] , g}); else v[g] = 1;
	}
	ddfs(1,0); vector < ll > leff;
	for(auto d : lef) if(hav[d.se] && d.fi < to[d.se]) hav[d.se] = 0; else leff.pb(d.fi);
	for(auto d : G[1]) if(hav[d.fi]) ned.pb(to[d.fi]);
	sort(ned.begin(),ned.end()); sort(leff.begin(),leff.end());
	for(int i = 0,j = 0;i < ned.size();i++) {
		while(j < leff.size() && leff[j] < ned[i]) j++;
		if(j == leff.size()) return 0; j++;
	}
	return 1;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in; for(int i = 1,u,v,w;i < n;i++) u = in,v = in,w = in,G[u].pb({v,w}),G[v].pb({u,w}),ans += w;
	m = in; for(int i = 1;i <= m;i++) match[i] = in;
	dfs(1,0);
	ll l = 0,r = ans + 10;
	while(l <= r) {
		ll mid = l + r >> 1;
		if(check(mid)) r = mid - 1; else l = mid + 1;
	}
	if(l > ans) puts("-1");
	else printf("%lld\n",l);
	return 0;
}
